package com.java.controller;

import com.java.entity.PageBean;
import com.java.entity.PsRole;
import com.java.entity.RespBean;
import com.java.service.PsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author caiyuan
 * @version 1.0
 * @Date 2020/6/18 10:30 Dream-Seeker
 * @Description
 */
@RestController
@RequestMapping("/role")
@Scope("prototype")
public class PsRoleController {

    @Autowired
    PsRoleService psRoleService;

    @GetMapping(value = "/allRole")
    public RespBean main(@RequestParam(value = "currentPage", defaultValue = "1", required = false) int currentPage,
                         Model model) {
        PageBean<PsRole> list = psRoleService.findByPage(currentPage);//回显分页数据
        if (null != list) {
            return RespBean.ok("page", list);
        } else {
            return RespBean.error("检查sql语句");
        }
    }
}
